home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 5.4 KB | 170 lines | [TEXT/ttxt] |
- in module DemoModule
-
- --*******************************************************************************
- --* Class name: Rollover
- --*
- --* Inherits from: RootObject
- --* Class type: Abstract, mixin
- --* Component: User Interface
- --*
- --* Description: This class provides the basic protocols for rollover
- --* functionality to any TwoDShape.
- --*
- --* This class can also be combined with a Button class to
- --* give you a Rollover Button.
- --*
- --* Usage: Create a new multi-inherited class
- --* class myRollover (TwoDShape, Rollover)
- --*
- --* IVs: enterBitmap
- --* exitBitmap
- --* authordata
- --* enterAction
- --* exitAction
- --* rolloverInterest
- --* enabled
- --*
- --* Methods: setEnterAppearance
- --* setExitAppearance
- --* mouseCross
- --* init
- --* afterInit
- --* afterLoading
- --*
- --* Required files: none
- --*
- --* Notes: If mixed with Button or Actuator, list Rollover class
- --* after them i.e. class RolloverButton (Button, Rollover)
- --* This is to ensure that when the enabled IV is set, the
- --* button changes its appearance to its disabled state.
- --*
- --* Author: Su Quek - Kaleida Labs, Inc.
- --*******************************************************************************
- class Rollover (RootObject)
- inst vars
- enterBitmap
- exitBitmap
- authordata
- enterAction
- exitAction
- rolloverInterest
- enabled : true
- end
-
- --*=============================================================================*
- --* Method name: setExitAppearance
- --* Class: Rollover
- --* Usage: setExitAppearance self
- --*-----------------------------------------------------------------------------*
- --* Description: Change the appearance of the shape to how it will appear
- --* when the mouse enter's the shape's boundary.
- --*=============================================================================*
- method setEnterAppearance self {class Rollover} ->
- (
- if (self.enterBitmap != undefined) do
- self.boundary := self.enterBitmap
- )
-
- --*=============================================================================*
- --* Method name: setExitAppearance
- --* Class: Rollover
- --* Usage: setExitAppearance self
- --*-----------------------------------------------------------------------------*
- --* Description: Change the appearance of the shape to how it will appear
- --* when the mouse leaves's the shape's boundary.
- --*=============================================================================*
- method setExitAppearance self {class Rollover} ->
- (
- if (self.exitBitmap != undefined) do
- self.boundary := self.exitBitmap
- )
-
- --*=============================================================================*
- --* Method name: mouseCross
- --* Class: Rollover
- --* Usage: mouseCross self interest event
- --*-----------------------------------------------------------------------------*
- --* Description: Displays and executes the appropriate bitmaps and actions
- --* when the mouse enters or leaves the shape's boundary
- --*=============================================================================*
- method mouseCross self {class Rollover} interest event ->
- (
- if not self.enabled do
- return
-
- if event.crossingType = @enter then
- (
- setEnterAppearance self
-
- if (self.enterAction != undefined) do
- self.enterAction self.authordata
- )
- else
- (
- setExitAppearance self
-
- if (self.exitAction != undefined) do
- self.exitAction self.authordata
- )
- )
-
- --*=============================================================================*
- --* Method name: init
- --* Class: Rollover
- --* Usage: init self
- --*-----------------------------------------------------------------------------*
- --* Description: Initializes its IVs
- --*=============================================================================*
- method init self {class Rollover} #rest args
- #key enterBitmap:(undefined) \
- exitBitmap:(undefined) ->
- (
- apply nextmethod self args
- self.exitBitmap := exitBitmap
- self.enterBitmap := enterBitmap
-
- self
- )
-
-
- --*=============================================================================*
- --* Method name: afterInit
- --* Class: Rollover
- --* Usage: afterInit self
- --*-----------------------------------------------------------------------------*
- --* Description: Sets up its appearance and mouse crossing event.
- --*=============================================================================*
- method afterInit self {class Rollover} #rest args ->
- (
- nextmethod self
- setExitAppearance self
-
- --*=========================================================================*
- --* Create mouse events.
- --*=========================================================================*
- local rolloverInterest
- rolloverInterest := new MouseCrossingEvent
- rolloverInterest.eventReceiver := mouseCross
- rolloverInterest.authorData := self
- rolloverInterest.device := new MouseDevice
- rolloverInterest.presenter := self
- addEventInterest rolloverInterest
-
- self.rolloverInterest := rolloverInterest
-
- self
- )
-
- --*=============================================================================*
- --* Method name: afterLoading
- --* Class: Rollover
- --* Usage: afterLoading self str
- --*-----------------------------------------------------------------------------*
- --* Description: Load the mouse crossing event.
- --*=============================================================================*
- method afterLoading self {class Rollover} str ->
- (
- nextmethod self str
- load self.rolloverInterest
- )
-